package com.zhiyou.serviceImpl;



import com.zhiyou.dao.RoleDao;
import com.zhiyou.daoImpl.RoleDaoImpl;

import com.zhiyou.model.Role;
import com.zhiyou.service.RoleService;
import com.zhiyou.util.PageBean;

public class RoleServiceImpl implements RoleService {

	@Override
	public PageBean<Role> show(int pc,int ps) {
		RoleDao rDao = new RoleDaoImpl();
		PageBean<Role> pageBean = rDao.findAll(pc, ps);
		return pageBean;
	}

	@Override
	public Role find(int id) {
		RoleDao rDao = new RoleDaoImpl();
		Role role = rDao.findById(id);
		return role;
	}

	
	@Override
	public boolean delete(int id) {
		RoleDao rDao = new RoleDaoImpl();
		boolean flag = rDao.delete(id);
		return flag;
	}

	
	@Override
	public boolean update(Role role) {
		RoleDao rDao = new RoleDaoImpl();
		boolean flag = rDao.update(role);
		return flag;
	}

	
	@Override
	public boolean add(String ro_name, String ro_desc) {
		RoleDao rDao = new RoleDaoImpl();
		boolean flag = rDao.add(ro_name, ro_desc);
		return flag;
	}

	@Override
	public boolean dels(int[] id) {
		// TODO Auto-generated method stub
		RoleDao rDao = new RoleDaoImpl();
		int id1[] = rDao.dels(id);
		for(int i = 0;i<id1.length;i++){
			if(id1[i] == 0){
				return false;
			}
		}
		return true;
	}

	@Override
	public PageBean<Role> find(String name, String desc, int pc, int ps) {
		RoleDao rDao = new RoleDaoImpl();
		PageBean<Role> pageBean = rDao.find(name, desc, pc, ps);
		return pageBean;
	}
	
	
}
